#ifndef AGENT_H
#define AGENT_H

#include "AISeek.h"
#include "AISteeringBehaviour.h"
#include "AISeperation.h"
#include "OOBB3Collision.h"
#include "AICohesion.h"

#include <D3D11.h>
#include <D3DX10math.h>
#include <map>

class AgentGroup;
class AISteeringBehaviour;

typedef std::pair<AISteeringBehaviour*, float> AISteeringBehaviourAndWeight;
typedef std::map<std::string, AISteeringBehaviourAndWeight> AIBehaviourMap;

class Agent/* : public AISteeringBehaviour*/
{
public:
	Agent();
	~Agent();
	
	void Draw();
	void Update();
	void DrawMiniMapElements();

	float GetMass();
	void SetMass(float mass);

	float GetMaxSpeed();
	void SetMaxSpeed(float speed);

	float GetMaxForce();
	void SetMaxForce(float force);

	float GetMaxTurnVel();
	void SetMaxTurnVel(float turnVel);
	
	D3DXVECTOR3& GetPosition();
	float GetXPos() {return m_oobb.centre.x;}
	void SetPosition(const D3DXVECTOR3& pos);
	
	D3DXVECTOR3& GetVel();
	void SetVel(const D3DXVECTOR3& vel);

	D3DXVECTOR3& GetMaxVel();
	void SetMaxVel(const D3DXVECTOR3& vel);
	
	D3DXVECTOR3& GetHeading();
	void GetHeading(const D3DXVECTOR3& heading);
	
	D3DXVECTOR3& GetSide();
	void SetSide(const D3DXVECTOR3& side);

	Agent*& GetTarget();
	void SetTarget(Agent* agent);

	Neighbours& GetNeighbours();
	void AddNeighbor(Agent* a);

	void SetGroup(AgentGroup* agentGroup);

	D3DXVECTOR3& GetForce();
	void SetForce(const D3DXVECTOR3& force);
	void AddForce(const D3DXVECTOR3& force);
		
	void SetColour(const D3DXVECTOR4& col);

	void SetAggressiveness(float f);
	float GetAggressiveness() const;

	OOBB3& GetOOBB();

private:
	void UpdatePosition();

private:
	float m_mass;
	float m_maxSpeed;
	float m_maxForce;
	float m_maxTurnVelocity;
	D3DXVECTOR3 m_maxVelocity;
	D3DXVECTOR3 m_velocity;
	D3DXVECTOR3 m_heading;
	D3DXVECTOR3 m_side;
	D3DXVECTOR3 m_force;
	Agent* m_target;

	AIBehaviourMap m_bhMap;
	AISeek m_seek;
	//AIFlee m_flee;

	Neighbours m_neighbours;
	AgentGroup* m_agentGroup;

	D3DXVECTOR4 m_colour;
	AISeperation m_seperate;
	AICohesion m_cohesion;
	D3DXVECTOR3 m_mazeCellSize;
	D3DXVECTOR2 m_mazeSize;

	OOBB3 m_oobb;
	float m_aggro; // detection radius
	float m_halfAggro;
	
	D3DXVECTOR3 m_mazePos;
	bool m_firstDraw;
};

#endif //AGENT_H